<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">

    <ui:define name="title">主体列表</ui:define>
    <ui:define name="content">
        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton value="新增" action="#{xhhSettlementCompanyListBean.onAdd}"
                                         icon="fa fa-plus"
                                         process="@this" rendered="true">
                            <f:setPropertyActionListener
                                    value="/views/settlementsystem/company-list.xhtml"
                                    target="#{currentUserBean.back}"/>
                        </p:commandButton>
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         update="@form"/>
                        <p:commandButton value="重置" actionListener="#{xhhSettlementCompanyListBean.onReset()}"
                                         icon="fa fa-refresh"
                                         process="@this" update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="xls" target="statisticRecordDataTable" fileName="主体列表"
                                            postProcessor="#{xhhSettlementCompanyListBean.postProcessXLS}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="ui-g-12 card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="4" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">

                                <p:outputLabel value="所属项目"/>
                                <p:selectOneMenu id="project" value="#{xhhSettlementCompanyListBean.$.billProject}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{settlementCompanyInfoBean.dictionaries[DictionaryCode.XHH_SETTLEMENT_BILLING_PROJECT]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>

                                <p:outputLabel value="开票主体"/>
                                <p:inputText id="companyName" value="#{xhhSettlementCompanyListBean.$.companyName}"/>

                                <p:outputLabel value="开票类型"/>
                                <p:selectOneMenu id="billType" value="#{xhhSettlementCompanyListBean.$.billType}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{xhhSettlementCompanyListBean.dictionaries[DictionaryCode.XHH_SETTLEMENT_BILL_TYPE]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>

                                <p:outputLabel value="创建人"/>
                                <p:inputText id="creator" value="#{xhhSettlementCompanyListBean.$.creator}"/>

                                <p:outputLabel value="创建时间"/>
                                <p:outputPanel>
                                    <p:calendar
                                            id="startTime" styleClass="autoWidthCalendar"
                                            value="#{xhhSettlementCompanyListBean.$.startTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                    <span>— </span>
                                    <p:calendar
                                            id="endTime" styleClass="autoWidthCalendar"
                                            value="#{xhhSettlementCompanyListBean.$.endTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                </p:outputPanel>
                            </p:panelGrid>
                        </div>


                        <div class="ui-g-12 card">
                            <p:dataTable id="statisticRecordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="record"
                                         value="#{xhhSettlementCompanyListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection=""
                                         resizableColumns="true">
                                <p:column headerText="操作" exportable="false" style="width:70px;">
                                    <p:splitButton icon="fa fa-eye"
                                                   process="@this"
                                                   action="#{xhhSettlementCompanyListBean.onSee(record.id)}">
                                        <f:setPropertyActionListener
                                                value="/views/settlementsystem/company-list.xhtml"
                                                target="#{currentUserBean.back}"/>

                                        <p:menuitem value="删除" icon="fa fa-remove"
                                                    rendered="#{security:areAllGranted('LOAN_SETTLEMENT_COMPANY_DELETE')}"
                                                    actionListener="#{xhhSettlementCompanyListBean.onDelete(record.id)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="提示信息" message="是否确定删除?" icon="ui-icon-alert"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column headerText="主体唯一id" style="width: 50px">
                                    <h:outputText value="#{record.id}"/>
                                </p:column>
                                <p:column headerText="所属项目" style="text-align:center;width: 70px;">
                                    <h:outputText
                                            value="#{xhhSettlementCompanyListBean.translate(DictionaryCode.XHH_SETTLEMENT_BILLING_PROJECT,record.billProject)}"/>
                                </p:column>
                                <p:column headerText="开票主体" style="width: 250px">
                                    <h:outputText value="#{record.companyName}"/>
                                </p:column>
                                <p:column headerText="是否开票" style="width: 60px">
                                    <h:outputText value="#{record.isBill==1?'是':'否'}"/>
                                </p:column>
                                <p:column headerText="发票类型" style="width:70px; text-align:center;">
                                    <h:outputText
                                            value="#{xhhSettlementCompanyListBean.translate(DictionaryCode.XHH_SETTLEMENT_BILL_TYPE,record.billType)}"/>
                                </p:column>
                                <p:column headerText="税务登记证号" style="text-align:center;width: 150px">
                                    <h:outputText value="#{record.taxNumber}"/>
                                </p:column>
                                <p:column headerText="预付金额" style="width:150px; text-align:center;">
                                    <h:outputText value="#{record.prepayAmount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="消耗金额" style="width:150px; text-align:center;">
                                    <h:outputText value="#{record.expendAmount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="剩余金额" style="width:150px; text-align:center;">
                                    <h:outputText value="#{record.prepayAmount - record.expendAmount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="创建人" style="width:100px; text-align:center;">
                                    <h:outputText value="#{record.creator}"/>
                                </p:column>
                                <p:column headerText="创建时间" style="width: 150px; text-align:center;">
                                    <h:outputText value="#{record.createTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>